import zConfirm from "./zConfirm/index.vue"
import { addDom } from "@/common.js"
import { createApp } from 'vue'
/**
 * 命令式调用二次确认弹框
 *@举例子
  _.$zConfirm({
    name: props.item.name, 
    content:'<div class="fs16">您确定要删除此数据集吗？</div> ', 
    onClose: () => {console.log('点击了close')}, 
    onCancel: () => {console.log('点击了cancel')}, 
    onConfirm: async () => {
      const res = await _.request(`/dataset/delete/${props.item.id}`, {type: 1}, {method: 'DELETE'})
      // ...
    }, 
  })
 * @param {Object} e 
 */
export function $zConfirm(e = { content:'', isShowClose: false, onClose: () => {}, onCancel: () => {}, onConfirm: () => {}}){
  const app = createApp(zConfirm, e)
  const divDom = addDom('', 'confirm_dom')
  app.mount(divDom)
}
